home *** CD-ROM | disk | FTP | other *** search
Wrap
unit Devices; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls, NCTAUDIOEDITOR2Lib_TLB, Src, Math, ComCtrls, Adv; type TfrmDevices = class(TForm) Label1: TLabel; Device: TComboBox; Panel1: TPanel; procedure DeviceClick(Sender: TObject); procedure FormShow(Sender: TObject); private { Private declarations } procedure SetSrcOutput; public { Public declarations } Dev: IAudioEditor2Device; srcCap: AnsiString; flg: Boolean; procedure TrackBarChange(Sender: TObject); procedure BalanceTrackBarChange(Sender: TObject); procedure SrcSelectChange(Sender: TObject); procedure AdvClick(Sender: TObject); end; var frmDevices: TfrmDevices; implementation {$R *.dfm} //--------------------------------------------------------------------------- procedure TfrmDevices.SetSrcOutput; var CountSrc: Integer; i: Integer; sf: TsrcFrame; begin CountSrc := Dev.DeviceLines.Count; for i := ComponentCount - 1 downto 3 do begin sf := TsrcFrame(Components[i]); sf.Destroy; end; Width := Max(255, CountSrc*79+94); Left := (Screen.Width - Width) div 2; if (CountSrc < 1) then Exit; for i:=ComponentCount - 3 to CountSrc do begin //Starts a cycle sf := TsrcFrame.Create(frmDevices); sf.Name := 'sfr'+ IntToStr(i); sf.Parent := frmDevices; sf.Left := i*79+4; sf.Top := 48; sf.Width := 81; Dev.DeviceLines.Num := i; //sets input source to the current number sf.Label1.Caption := Dev.DeviceLines.Name; //Sets srcOutput Caption to the src Input device name sf.TrackBar1.Position := 65535 - Dev.DeviceLines.Volume; //sets volume value according to the movement of the slider sf.TrackBar1.Tag := i; sf.TrackBar1.OnChange := TrackBarChange; sf.TrackBar2.Position := Dev.DeviceLines.VolumeBalance; //sets balance value according to the slider position sf.TrackBar2.Tag := i; sf.TrackBar2.OnChange := BalanceTrackBarChange; if (srcCap='Select') then sf.CheckBox1.Checked := Dev.DeviceLines.Select else sf.CheckBox1.Checked := Not Dev.DeviceLines.Select; sf.CheckBox1.Tag := i; sf.CheckBox1.OnClick := SrcSelectChange; sf.CheckBox1.Caption := srcCap; sf.Button1.Tag := i; if (Dev.DeviceLines.AdvancedCount >= 0) then sf.Button1.Visible := True //if the current Src has any advanced options then show 'Advanced' button else sf.Button1.Visible := False; //otherwise show no buttons sf.Button1.OnClick := AdvClick; end; end; //--------------------------------------------------------------------------- procedure TfrmDevices.DeviceClick(Sender: TObject); begin Dev.Num := Integer(Device.Items.Objects[Device.ItemIndex]); SetSrcOutput(); end; //--------------------------------------------------------------------------- procedure TfrmDevices.FormShow(Sender: TObject); var kDevInput: Integer; i: Integer; begin kDevInput := Dev.Num; //otherwise kDevOutput equals to the number of output devices on the current machine Device.Items.Clear(); for i:=0 to Dev.Count do begin //Start cycle which checks if the current device is able to play sound Dev.Num := i; //Sets number of output device to 'i' Device.Items.AddObject(Dev.Name, TObject(i)); if (Dev.DeviceLines.Count < 1) then begin if (i = kDevInput) then kDevInput := kDevInput + 1; end; end; if (kDevInput > Dev.Count) then kDevInput := 0; //if the number of the alst of all the audio devices is more than number of devices which are able to playback sound Dev.Num := kDevInput; //the number of device for audio output is set to the last device 'been checked Device.ItemIndex := kDevInput; //the current device to be shown in the Combo box is set to the last device 'been checked SetSrcOutput(); end; //--------------------------------------------------------------------------- procedure TfrmDevices.TrackBarChange(Sender: TObject); var TrackBar: TTrackBar; pos: TPoint; begin TrackBar := TTrackBar(Sender); TrackBar.Hint := IntToStr(65535-TrackBar.Position); GetCursorPos(pos); Application.ActivateHint(pos); Dev.DeviceLines.Num := TrackBar.Tag; Dev.DeviceLines.Volume := 65535-TrackBar.Position; end; //--------------------------------------------------------------------------- procedure TfrmDevices.AdvClick(Sender: TObject); var Button: TButton; frm: TfrmAdv; begin Button := TButton(Sender); Dev.DeviceLines.Num := Button.Tag; frm := TfrmAdv.Create(frmDevices); frm.m_Rec := True; frm.ShowModal(); frm.Destroy; end; //--------------------------------------------------------------------------- procedure TfrmDevices.BalanceTrackBarChange(Sender: TObject); var TrackBar: TTrackBar; begin TrackBar := TTrackBar(Sender); Dev.DeviceLines.Num := TrackBar.Tag; Dev.DeviceLines.VolumeBalance := TrackBar.Position; end; //--------------------------------------------------------------------------- procedure TfrmDevices.SrcSelectChange(Sender: TObject); var CheckBox: TCheckBox; sf: TsrcFrame; CountSrc: Integer; i: Integer; begin if (flg) then Exit; flg := True; CheckBox := TCheckBox(Sender); Dev.DeviceLines.Num := CheckBox.Tag; if (srcCap = 'Select') then Dev.DeviceLines.Select := CheckBox.Checked else Dev.DeviceLines.Select := Not CheckBox.Checked; CountSrc := Dev.DeviceLines.Count; for i:=3 to CountSrc+2 do begin //Starts a cycle Dev.DeviceLines.Num := i-3; //sets input source to the current number sf := TsrcFrame(Components[i]); if (srcCap = 'Select') then sf.CheckBox1.Checked := Dev.DeviceLines.Select else sf.CheckBox1.Checked := Not Dev.DeviceLines.Select; end; flg := False; end; //--------------------------------------------------------------------------- end.